package ruifight.member.controller;

import com.github.pagehelper.PageInfo;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import ruifight.member.model.CarInfo;
import ruifight.member.model.ClassifyInfo;
import ruifight.member.service.CarInfoService;
import ruifight.member.service.ClassifyInfoService;
import ruifight.member.util.ObjUtil;

import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;


@Controller
@RequestMapping("/interface")
public class CarInfoController {

	private static final Logger logger = LoggerFactory.getLogger(CarInfoController.class);

	@Autowired
	public CarInfoService carInfoService;

	/**
	 * 获取车辆信息
	 * @return
	 */
	@RequestMapping("/getCarInfo")
	@ResponseBody
	public CarInfo getCarInfo(@RequestBody Map<String, Object> paramMap) {
		CarInfo carInfo = carInfoService.getCarInfo(paramMap);
		return carInfo;
	}

	/**
	 * 修改车辆信息
	 * @param carInfo
	 * @return
	 */
	@RequestMapping("/updateCarInfo")
	@ResponseBody
	public  Map<String, Object> updateCarInfo(@RequestBody CarInfo carInfo) {
		Map<String, Object> map = new HashMap<String, Object>();
		try {
			carInfoService.updateByPrimaryKeySelective(carInfo);
			map.put("state", 1);
			map.put("msg", "修改成功");
		} catch (Exception e) {
			map.put("state", 0);
			map.put("msg", "修改失败");
			e.printStackTrace();
		}
		return map;
	}

}
